//
//  ZSLeftMessageCell.swift
//  creativeassistant
//
//  Created by 灵工邦 on 2025/2/13.
//

import UIKit

class ZSLeftMessageCell: UITableViewCell {
    
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var copyButton: UIButton!
    @IBOutlet weak var copyTop: NSLayoutConstraint!
    @IBOutlet weak var copyHeight: NSLayoutConstraint!
    
    var model: ZSAssistantMessageModel? {
        didSet {
            guard let model = model else { return }
            contentLabel.text = model.message
            if model.isSelect {
                self.copyTop.constant = 5
                self.copyHeight.constant = 21
                self.copyButton.isHidden = false
            }else {
                self.copyTop.constant = 0
                self.copyHeight.constant = 0
                self.copyButton.isHidden = true
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
    
    @IBAction func didCopy(_ sender: UIButton) {
        if let model = model {
            UIPasteboard.general.string = model.message
            UIApplication.shared.keyWindow?.makeToast("复制成功", position: .center)
        }
    }
    
    
}
